<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style>
        .item{
            list-style: none;
            color:red;
        }
    </style>
</head>
<body>
<!--vue的基本使用-->
<div id="app">
    {{msg}}
    <div>
        <input type="text" v-model="info">
        <button @click="handleClick">添加</button>
    </div>
    <ul>
        <!--<li v-for="item in list">{{item}}</li>-->
        <todo-item v-for="item in list" :item="item"></todo-item>
    </ul>

</div>

<script>
    Vue.component('todo-item',{
        props:['item'],
        template:'<li class="item">{{item}}</li>'
    })
    new Vue({
        el:'#app',
        data(){
            return {
                msg:"hello vue",
                info:'',
                list:[],
            }
        },
        methods:{
            handleClick(){
                console.log(this.info)
                this.list.push(this.info)
                this.info=''
            }
        }
    })
</script>

</body>
</html>